<template>
  <div>
    <!-- 顶部导航栏 -->
    <header class="header">
      <div class="left">欢迎：{{ user?.username }}</div>
      <div class="nav-links">
        <a href="https://gitee.com/li0802/vue_pinia" target="_blank" rel="noopener noreferrer">
          <i class="fa fa-github"></i> Gitee仓库
        </a>
        <router-link to="/todo">📋 Todolist</router-link>
        <router-link to="/screenshot">🖼️ 测试截图</router-link>
        
        <button @click="logout">🚪 退出</button>
      </div>
    </header>

    <!-- 主体内容 -->
    <main class="main-content">
      <router-view />
    </main>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { ref } from 'vue';

const router = useRouter()
const auth = useAuthStore()
const user = ref(auth.user); // 假设 auth 中有 user 对象包含 username

const logout = () => {
  auth.logout()
  router.push('/login')
}
</script>

<style scoped>
/* 顶部导航栏样式 */
.header {
  display: flex;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  /* 使用二次元风格的渐变背景 */
  background: linear-gradient(135deg, #ffc0cb 0%, #87cefa 100%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border-radius: 0 0 20px 20px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

/* 左侧欢迎信息样式 */
.left {
  display: flex;
  align-items: center;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  font-size: 1.5em;
  font-weight: 600;
  color: #ff69b4;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

/* 导航链接样式 */
.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a,
.nav-links button {
  text-decoration: none;
  background-color: #ff69b4;
  color: white;
  padding: 12px 20px;
  border-radius: 15px;
  border: none;
  cursor: pointer;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  font-size: 1.2em;
  transition: background-color 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links a:hover,
.nav-links button:hover {
  background-color: #ff1493;
  transform: scale(1.05);
}

/* 主体内容样式 */
.main-content {
  padding: 2rem;
  min-height: calc(100vh - 100px);
  background-color: rgba(255, 255, 255, 0.8);
}
</style>